﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DomainDriver.CommonUtilities.Collections;
using DomainDriver.DomainModeling.DomainObjects;

namespace DomainDriver.DomainModeling.Queries
{
    public class QuerySpecification : DomainObjectBase<QuerySpecification>
    {
        private Type m_QueryType;
        private string[] m_Parameters;

        public QuerySpecification(Type queryType, string[] parameters)
        {
            m_QueryType = queryType;
            m_Parameters = parameters;
        }

        public Type QueryType
        {
            get { return m_QueryType; }
        }

        public string[] Parameters
        {
            get { return m_Parameters; }
        }

        public override QuerySpecification Copy()
        {
            QuerySpecification copy = new QuerySpecification(null, new string[] { });
            CopyTo(copy);
            return copy;
        }

        public override void CopyTo(QuerySpecification otherObject)
        {
            otherObject.m_QueryType = m_QueryType;
            otherObject.m_Parameters = m_Parameters.ToArray<string>();
        }

        public override bool Equals(QuerySpecification otherObject)
        {
            if (!otherObject.m_QueryType.Equals(m_QueryType))
            { return false; }
            if (!CollectionUtilities.AreUnorderedCollectionsEqual(otherObject.m_Parameters, m_Parameters))
            { return false; }
            return true;
        }
    }
}